<include file="Public/header" title="{$Think.config.PWD_NAME}" />
<include file="Public/navbar" />
<div class="container">
    <h3>新增密码</h3>
    <form action="" method="post">
    <div class="form-group">
        <label for="parent_id">类别</label>
        <select class="form-control" name="category_id">
        <option value="0">请选择类别</option>
        {$parent_id_options}
        </select>
    </div>
    <div class="form-group">
        <label for="title">标题</label>
        <input type="text" class="form-control" name="title" id="title" placeholder="">
    </div>
    <div class="form-group">
        <label for="user_name">用户名</label>
        <input type="text" class="form-control" name="user_name" id="user_name" placeholder="">
    </div>
    <div class="form-group">
        <label for="user_password">密码</label>
        <div class="input-group">
            <input type="text" class="form-control" name="user_password" id="user_password" placeholder="">
            <span class="input-group-addon" id="im_feeling">试试手气</span>
        </div>
    </div>
    <div class="form-group">
        <label for="remark">备注</label>
        <textarea class="form-control" name="remark" id="remark" rows="5"></textarea>
    </div>
    <button type="submit" class="btn btn-primary">添加</button>
    </form>
</div>
<script type="text/javascript">
jQuery(function($) {
	function rand(max) {
		return Math.floor(Math.random() * max);
	};
	$('#im_feeling').click(function() {
		var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var pwd_unique = true;
		var pwd_length = 10;
		var _chars = chars.split(""),
		pwd = "";
		for(var j=0; j<pwd_length; j++) {
			if(1 > _chars.length) {
				break;
			}
			var index = rand(_chars.length);
			pwd += _chars[index];
			if(pwd_unique) {
				_chars.splice(index, 1);
			}
		}
		$('#user_password').val(pwd);
	});
});
</script>
<include file="Public/footer" />